#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int takeAttendance(vector<int>& records)
    {
        int n = records.size();
        int left = 0, right = n - 1;
        while (left < right)
        {
            int mid = (right - left) / 2 + left;
            if (records[mid] == mid)
                left = mid + 1;
            else
                right = mid;
        }
        return records[left] == left ? left + 1 : left;
    }
};